#!/bin/sh
traff_path='/opt/YAMon/data/'
traff_list=` nvram show|grep traff-|cut -f1 -d=`
index=1
traff=`echo "$traff_list" | sed -n "$index"'p'`

while [ -n "$traff" ];
do
    echo $traff
    fn="$traff_path$traff.data"
    touch "$fn"
    dayno=1
    data=`nvram show | grep "$traff" | cut -d= -f2 | cut -d' ' -f$dayno`
   
    while [ -n "$data" ]; do
        d1=`echo "$data" | cut -d: -f1`
        d2=`echo "$data" | cut -d: -f2`
        echo "FF:FF:FF:FF:FF:FF,1.1.1.1,$d1,$d2,$dayno" >> $fn
        dayno=`expr $dayno + 1`
        data=`nvram show | grep "$traff" | cut -d= -f2 | cut -d' ' -f$dayno`
    done
    index=`expr $index + 1`
    traff=`echo "$traff_list" | sed -n "$index"'p'`
done

